using System;
using Xunit;
using FrameIdentityReq;
using Param;
using System.Net;

namespace xUnitTest
{
    public class TestArgs
    {
        [Fact]
        void Test()
        {

            Args aArgs;

            aArgs = new Args();
            aArgs.Parse(new string[0]);
            Assert.Null(aArgs.GetValue(""));

            aArgs.Parse("127.0.0.1".Split(" "));
            Assert.Equal("127.0.0.1", aArgs.GetValue(""));

            aArgs = new Args();
            aArgs.Parse("127.0.0.1 123456 abcdefg".Split(" "));
            Assert.Equal("127.0.0.1", aArgs.GetValue("-a"));
            Assert.Equal("123456", aArgs.GetValue("-b"));
            Assert.Equal("abcdefg", aArgs.GetValue("-c"));

            aArgs = new Args();
            aArgs.Parse("-abc 127.0.0.1 -def 123456 -ghi abcdefg".Split(" "));
            Assert.Null(aArgs.GetValue("-a"));
            Assert.Equal("127.0.0.1", aArgs.GetValue("-abc"));
            Assert.Equal("123456", aArgs.GetValue("-DEF"));
            Assert.Equal("abcdefg", aArgs.GetValue("-Ghi"));

            aArgs = new Args();
            aArgs.Parse("-abc 127.0.0.1 123456 -ghi abcdefg".Split(' '));
            Assert.Equal("127.0.0.1", aArgs.GetValue("-abc"));
            Assert.Equal("123456", aArgs.GetValue("-DEF"));
            Assert.Equal("abcdefg", aArgs.GetValue("-Ghi"));
            Assert.Null(aArgs.GetValue("-a"));

            aArgs = new Args();
            aArgs.Parse("127.0.0.1 123456 -ghi abcdefg".Split(" "));
            Assert.Equal("127.0.0.1", aArgs.GetValue("-abc"));
            Assert.Equal("123456", aArgs.GetValue("-DEF"));
            Assert.Equal("abcdefg", aArgs.GetValue("-Ghi"));
            Assert.Null(aArgs.GetValue("-a"));

            aArgs = new Args();
            aArgs.Parse("127.0.0.1 123456 -x -ghi abcdefg".Split(" "));
            Assert.Equal("127.0.0.1", aArgs.GetValue("-abc"));
            Assert.Equal("123456", aArgs.GetValue("-DEF"));
            Assert.Equal("abcdefg", aArgs.GetValue("-Ghi"));
            Assert.Equal("", aArgs.GetValue("-x"));
            Assert.Null(aArgs.GetValue("-a"));

            aArgs = new Args();
            aArgs.Parse("127.0.0.1 123456 -x -x 789 -z -ghi abcdefg -y".Split(" "));
            Assert.Equal("127.0.0.1", aArgs.GetValue("-abc"));
            Assert.Equal("123456", aArgs.GetValue("-DEF"));
            Assert.Equal("abcdefg", aArgs.GetValue("-Ghi"));
            Assert.Equal("", aArgs.GetValue("-x"));
            Assert.Equal("", aArgs.GetValue("-z"));
            Assert.Equal("", aArgs.GetValue("-y"));
            Assert.Null(aArgs.GetValue("-a"));
        }
    }
}